﻿
Imports std

Public Class stringSerial
    Public Class serial
        Public vs As [set](Of String) = Nothing

        Public Function match(ByVal i As String) As Boolean
            If vs Is Nothing Then
                debugassert(False, "vs is a nothing [set](of string) instance.")
                Return False
            Else
                Return vs.find(i) <> vs.end()
            End If
        End Function
    End Class

    'leave this changeable, for some special requirements
    Public Shared separators As String = character.minusSign + character.sheffer

    Public Shared Function match(ByVal i As String, ByVal ser As String) As Boolean
        Dim serial As serial = Nothing
        If parseSerial(ser, serial) Then
            If serial Is Nothing Then
                debugassert(False, "serial is a nothing serial instance.")
                Return False
            Else
                Return serial.match(i)
            End If
        Else
            Return False
        End If
    End Function

    Public Shared Function parseSerial(ByVal i As String, ByRef ser As serial) As Boolean
        Dim v As vector(Of String) = Nothing
        strsepar(i, separators, v, True)
        If ser Is Nothing Then
            ser = New serial()
        End If
        Return vector2set(v, ser.vs)
    End Function
End Class
